import { BasicColumn, FormSchema } from '@/components/Table';
import { h, ref } from 'vue';
import { Tag } from 'ant-design-vue';
import { ywUserSelectList } from '@/api/heng/ywManage';
import { ApiSelect } from '@/components/Form';
import util from '@/utils/util';
import { useMessage } from '@/hooks/web/useMessage';
import { VxeFormItemProps, VxeGridPropTypes } from '@/components/VxeTable';

export function openModal(record) {
  console.log('--record ', record);
}

type CheckedType = boolean | string | number;
// BasicColumn[]

// VxeColumnPropTypes.CellRender

export const vxeTableFormSchema: VxeFormItemProps[] = [
  {
    span: 5,
    field: 'orderNoLike',
    title: '查询',
    itemRender: {
      props: {
        placeholder: '来源单据编号',
      },
      name: 'AInput',
    },
  },
  // {
  //   span: 5,
  //   field: 'state0',
  //   title: 'ms审批状态',
  //   itemRender: {
  //     name: 'ASelect',
  //     defaultValue: 9999,
  //     props: {
  //       options: [
  //         { label: '已审批', value: 9999 },
  //         { label: '审批中', value: 0 },
  //         { label: '需修改', value: -1 },
  //       ],
  //       style: { width: '100%' },
  //     },
  //   },
  // },
  {
    span: 5,
    field: 'xiaoShouDingDanTIDLike',
    title: '销售单号',
    itemRender: {
      props: {
        placeholder: '请输入销售单号',
      },
      name: 'AInput',
    },
  },

  // {
  //   span: 5,
  //   field: 'userNameLogin',
  //   title: '模拟登录人员',
  //   itemRender: {
  //     props: {
  //       placeholder: '人员名称',
  //     },
  //     name: 'AInput',
  //   },
  // },
  {
    span: 5,
    field: 'dateArr',
    title: '收款日期区间',
    itemRender: {
      props: {
        valueFormat: 'YYYY-MM-DD',
        format: 'YYYY-MM-DD',
      },
      name: 'ARangePicker',
    },
  },
  {
    span: 5,
    itemRender: {
      name: 'VxeButtonGroup',
      options: [
        { type: 'reset', content: '重置' },
        { type: 'submit', content: '查询', status: 'primary' },
      ],
    },
  },
];

export const rules = {
  mouldNameObj: [{ required: true, message: '费用名称不能为空', trigger: 'change' }],
  materialNo: [
    { required: true, message: '物料编号不能为空', trigger: 'change' },
    { min: 3, max: 5, message: 'Length should be 3 to 5', trigger: 'blur' },
  ],
  orderNo: [
    { required: true, message: '采购单号不能为空', trigger: 'change' },
    { min: 3, max: 5, message: 'Length should be 3 to 5', trigger: 'blur' },
  ],
};

/**
 * 确认提交审批列表
 */

export const confirmColumns: VxeGridPropTypes.Columns = [
  {
    title: '单据来源编号',
    field: 'orderNo',
    showOverflow: 'title',
    width: 130,
  },
  {
    title: '类型',
    field: 'type',
    showOverflow: 'title',
    align: 'center',
    width: 100,
  },

  {
    title: '金额(人民币)',
    field: 'totalAllPrice',
    showOverflow: 'title',
    slots: {
      footer: 'footer_totalAllPrice',
    },
    width: 100,
  },
  {
    title: '订单抽成金额',
    field: 'orderCommissionPrice0',
    slots: {
      footer: 'footer_orderCommissionPrice',
    },
    showOverflow: 'title',
    width: 100,
  },

  {
    title: '接单人',
    field: 'receiverUserName0',
    align: 'center',
    width: 60,
  },
  {
    title: '接单人抽成金额',
    field: 'receiverUserPrice0',
    slots: {
      footer: 'footer_receiverUserPrice',
    },
    align: 'center',
    width: 60,
  },

  {
    title: '跟单人',
    field: 'merchandiserUserName0',
    align: 'center',
    width: 60,
  },
  {
    title: '跟单人抽成金额',
    field: 'merchandiserUserPrice0',
    slots: {
      footer: 'footer_merchandiserUserPrice',
    },
    align: 'center',
    width: 60,
  },
  {
    title: '介绍人',
    field: 'introduceUserName',
    // filters: [{ data: '' }],
    // filterRender: {
    //   name: 'VxeInput',
    // },
    align: 'center',
    width: 60,
  },
  {
    title: '介绍人抽成',
    field: 'introduceUserPrice',
    align: 'center',
    width: 60,
    // slots: {
    //   footer: "footer_merchandiserUserPrice"
    // }
  },
  {
    title: '业务经理',
    field: 'manageUserName0',
    align: 'center',
    width: 70,
  },
  {
    title: '经理抽成',
    field: 'manageUserPrice0',
    slots: {
      footer: 'footer_manageUserPrice',
    },
    align: 'center',
    width: 90,
  },
  {
    title: '项目组',
    field: 'xiangMuGroupName0',
    align: 'center',
    width: 70,
  },
  {
    title: '项目组抽成',
    field: 'xiangMuGroupPrice0',
    slots: {
      footer: 'footer_xiangMuGroupPrice',
    },
    align: 'center',
    width: 90,
  },
  {
    width: 80,
    title: '操作',
    align: 'center',
    slots: { default: 'action' },
    fixed: 'right',
  },
];

/**
 * 发票核销明细列
 */

export const fapiaoColumns: VxeGridPropTypes.Columns = [
  {
    title: '收款确认编号',
    field: 'skqrNo',
    showOverflow: 'title',
    width: 130,
  },
  {
    title: '发票编号',
    field: 'zhuTID',
    showOverflow: 'title',
    width: 130,
  },
  {
    title: '物料编号',
    field: 'wuLiaoBianHao',
    showOverflow: 'title',
    align: 'center',
    width: 100,
  },

  {
    title: '物料名称',
    field: 'wuLiaoMingCheng',
    showOverflow: 'title',
    align: 'center',
    width: 100,
  },
  {
    title: '物料型号',
    field: 'xingHao',
    showOverflow: 'title',
    align: 'center',
    width: 100,
  },
  {
    title: '来源单据类型',
    field: 'laiYuanDanJuLeiXing',
    showOverflow: 'title',
    align: 'center',
    width: 100,
  },
  {
    title: '领用性质',
    field: 'lingYongXingZhi',
    showOverflow: 'title',
    align: 'center',
    width: 100,
  },
  {
    title: '批次号',
    field: 'piCiHao',
    showOverflow: 'title',
    align: 'center',
    width: 100,
  },
  {
    title: '销售订单号',
    field: 'xiaoShouDingDanTID',
    showOverflow: 'title',
    align: 'center',
    width: 100,
  },

  {
    title: '确认到货金额',
    field: 'queRenDaoHuoJinE',
    showOverflow: 'title',
    align: 'center',
    width: 100,
  },
  {
    title: '确认到货人民币金额',
    field: 'queRenDaoHuoRenMinBiJinE',
    showOverflow: 'title',
    align: 'center',
    width: 100,
  },
];

/**
 * 预收款明细列
 */

export const yuhsouColumns: VxeGridPropTypes.Columns = [
  {
    title: '预收款编号',
    field: 'skqrNo',
    showOverflow: 'title',
    width: 130,
  },
  {
    title: '物料编号',
    field: 'wuLiaoBianHao',
    showOverflow: 'title',
    align: 'center',
    width: 100,
  },

  {
    title: '物料名称',
    field: 'wuLiaoMingCheng',
    showOverflow: 'title',
    align: 'center',
    width: 200,
  },
  {
    title: '物料型号',
    field: 'xingHao',
    showOverflow: 'title',
    align: 'center',
    width: 200,
  },
  {
    title: '性质',
    field: 'lingYongXingZhi',
    showOverflow: 'title',
    align: 'center',
    width: 100,
  },
  {
    title: '销售订单号',
    field: 'xiaoShouDingDanTID',
    showOverflow: 'title',
    align: 'center',
    width: 100,
  },

  {
    title: '确认到货金额',
    field: 'queRenDaoHuoJinE',
    showOverflow: 'title',
    align: 'center',
    width: 100,
  },
  {
    title: '确认到货人民币金额',
    field: 'queRenDaoHuoRenMinBiJinE',
    showOverflow: 'title',
    align: 'center',
    width: 100,
  },
];

/**
 * 导出excel 列
 */
export const exportColumns: VxeGridPropTypes.Columns = [
  {
    title: '发票编号',
    field: 'zhuTID',
    showOverflow: 'title',
    width: 130,
  },
  {
    title: '物料编号',
    field: 'wuLiaoBianHao',
    showOverflow: 'title',
    align: 'center',
    width: 100,
  },

  {
    title: '物料名称',
    field: 'wuLiaoMingCheng',
    showOverflow: 'title',
    align: 'center',
    width: 100,
  },
  {
    title: '来源单据类型',
    field: 'laiYuanDanJuLeiXing',
    showOverflow: 'title',
    align: 'center',
    width: 100,
  },
  // {
  //   title: '领用性质',
  //   field: 'lingYongXingZhi',
  //   showOverflow: 'title',
  //   align: 'center',
  //   width: 100,
  // },
  {
    title: '销售订单号',
    field: 'xiaoShouDingDanTID',
    showOverflow: 'title',
    align: 'center',
    width: 100,
  },

  {
    title: '确认到货金额',
    field: 'queRenDaoHuoJinE',
    showOverflow: 'title',
    align: 'center',
    width: 100,
  },

  {
    title: '确认到货人民币金额',
    field: 'queRenDaoHuoRenMinBiJinE',
    showOverflow: 'title',
    align: 'center',
    width: 100,
  },
];

export const addExcludeColumns: VxeGridPropTypes.Columns = [
  {
    title: '单据来源编号',
    field: 'orderNo',
    showOverflow: 'title',
    width: 130,
  },
  {
    title: '类型',
    field: 'type',
    showOverflow: 'title',
    align: 'center',
    width: 100,
  },

  {
    title: '金额(人民币)',
    field: 'totalAllPrice',
    showOverflow: 'title',
    slots: {
      footer: 'footer_totalAllPrice',
    },
    width: 100,
  },
  {
    title: '订单抽成金额',
    field: 'orderCommissionPrice0',
    slots: {
      footer: 'footer_orderCommissionPrice',
    },
    showOverflow: 'title',
    width: 100,
  },

  {
    title: '接单人',
    field: 'receiverUserName0',
    align: 'center',
    width: 100,
  },
  {
    title: '接单人抽成金额',
    field: 'receiverUserPrice0',
    slots: {
      footer: 'footer_receiverUserPrice',
    },
    align: 'center',
    width: 100,
  },

  {
    title: '跟单人',
    field: 'merchandiserUserName0',
    align: 'center',
    width: 100,
  },
  {
    title: '跟单人抽成金额',
    field: 'merchandiserUserPrice0',
    slots: {
      footer: 'footer_merchandiserUserPrice',
    },
    align: 'center',
    width: 100,
  },

  {
    title: '业务经理',
    field: 'manageUserName0',
    align: 'center',
    width: 70,
  },
  {
    title: '经理抽成',
    field: 'manageUserPrice0',
    slots: {
      footer: 'footer_manageUserPrice',
    },
    align: 'center',
    width: 90,
  },
  {
    title: '项目组',
    field: 'xiangMuGroupName0',
    align: 'center',
    width: 70,
  },
  {
    title: '项目组抽成',
    field: 'xiangMuGroupPrice0',
    slots: {
      footer: 'footer_xiangMuGroupPrice',
    },
    align: 'center',
    width: 90,
  },
  {
    width: 80,
    title: '操作',
    align: 'center',
    slots: { default: 'action' },
    fixed: 'right',
  },
];
export const getExcludeColumns: VxeGridPropTypes.Columns = [
  {
    title: '单据来源编号',
    field: 'orderNo',
    showOverflow: 'title',
    width: 130,
  },
  {
    title: '类型',
    field: 'type',
    showOverflow: 'title',
    align: 'center',
    width: 100,
  },

  {
    title: '金额(人民币)',
    field: 'totalAllPrice',
    showOverflow: 'title',
    slots: {
      footer: 'footer_totalAllPrice',
    },
    width: 100,
  },
  {
    title: '订单抽成金额',
    field: 'orderCommissionPrice',
    slots: {
      footer: 'footer_orderCommissionPrice',
    },
    showOverflow: 'title',
    width: 100,
  },

  {
    title: '接单人',
    field: 'receiverUserName',
    align: 'center',
    width: 100,
  },
  {
    title: '接单人抽成金额',
    field: 'receiverUserPrice',
    slots: {
      footer: 'footer_receiverUserPrice',
    },
    align: 'center',
    width: 100,
  },

  {
    title: '跟单人',
    field: 'merchandiserUserName',
    align: 'center',
    width: 100,
  },
  {
    title: '跟单人抽成金额',
    field: 'merchandiserUserPrice',
    slots: {
      footer: 'footer_merchandiserUserPrice',
    },
    align: 'center',
    width: 100,
  },

  {
    title: '业务经理',
    field: 'manageUserName',
    align: 'center',
    width: 70,
  },
  {
    title: '经理抽成',
    field: 'manageUserPrice',
    slots: {
      footer: 'footer_manageUserPrice',
    },
    align: 'center',
    width: 90,
  },
  {
    title: '项目组',
    field: 'xiangMuGroupName',
    align: 'center',
    width: 70,
  },
  {
    title: '项目组抽成',
    field: 'xiangMuGroupPrice',
    slots: {
      footer: 'footer_xiangMuGroupPrice',
    },
    align: 'center',
    width: 90,
  },
  {
    title: '操作人',
    field: 'userName',
    align: 'center',
    width: 70,
  },
  {
    width: 80,
    title: '操作',
    align: 'center',
    slots: { default: 'action' },
    fixed: 'right',
  },
];
